//
//  SINAStringUtils.m
//  sinashebao
//
//  Created by  androidlongs on 2018/1/25.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINAStringUtils.h"

@implementation SINAStringUtils

//加密
+(NSString *) encodeBase64String:(NSString*) decodeString{
    NSData *encodeData = [decodeString dataUsingEncoding:NSUTF8StringEncoding];
    NSString *base64String = [encodeData base64EncodedStringWithOptions:0];
    return  base64String;
}
//解密
+(NSString *) decodeBase64String:(NSString*) base64String{
    NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:base64String options:0];
    NSString *decodedString = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding];
    return  decodedString;
}

+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString
{
    if (jsonString == nil) {
        return nil;
    }
    
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingMutableContainers
                                                          error:&err];
    if(err)
    {
        DLog(@"json解析失败：%@",err);
        return nil;
    }
    return dic;
}

@end
